﻿using UnityEngine;
using System.Collections.Generic;

namespace Room
{
    public class SceneCamera
    {
        public Camera camera;
        public Transform target;

        public Vector3 offset;
        public Vector3 angle;

        public SceneCamera (Camera c,Transform target)
        {
            this.camera = c;
            this.target = target;
        }

        public void Set(Vector3 offset,Vector3 angle,float fieldOfView)
        {
            this.offset = offset;
            this.angle = angle;
            camera.transform.eulerAngles = angle;
            camera.fieldOfView = fieldOfView;
        }

        public float getCameraRotate()
        {
            return this.angle.y;
        }

        public void SetTarget(Transform target)
        {
            this.target = target;
        }

        public void Tick()
        {
            if(target != null)
            {
                camera.transform.position = target.position + offset;
                camera.transform.localEulerAngles = angle;
            }
        }
    }
}
